package pl.nazaweb.imedproplus.model.entity;

import pl.nazaweb.imedproplus.model.interfaces.IIcd9;
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@Entity
@Table(name = "icd9")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Icd9.findAll", query = "SELECT i FROM Icd9 i"),
    @NamedQuery(name = "Icd9.findByCode", query = "SELECT i FROM Icd9 i WHERE i.code = :code"),
    @NamedQuery(name = "Icd9.findAllCode", query = "SELECT i.code FROM Icd9 i"),
    @NamedQuery(name = "Icd9.findByName", query = "SELECT i FROM Icd9 i WHERE i.name = :name")})
public class Icd9 implements Serializable, IIcd9 {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "code")
    private String code;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 500)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "status")
    private String status;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "procedure")
    private List<VisitProcedure> visitProcedureList;

    public Icd9() {
    }

    public Icd9(String code) {
        this.code = code;
    }

    public Icd9(String code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public void setCode(String code) {
        this.code = code;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    @Override
    public List<VisitProcedure> getVisitProcedureList() {
        return visitProcedureList;
    }

    @Override
    public void setVisitProcedureList(List<VisitProcedure> visitProcedureList) {
        this.visitProcedureList = visitProcedureList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (code != null ? code.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Icd9)) {
            return false;
        }
        Icd9 other = (Icd9) object;
        if ((this.code == null && other.code != null) || (this.code != null && !this.code.equals(other.code))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pl.nazaweb.imedproplus.model.entity.Icd9[ code=" + code + " ]";
    }
}
